<?php
namespace Home\Controller;
class OrderController extends CommonController {
	protected $m;
	protected $pagesize;
	
	function _initialize() {
		parent::_initialize();
		$this->m = D('YgclOrder');
		$this->pagesize = 10;
	}
	
	
    public function index(){
		$this->list = $this->_get_order(1, $this->pagesize);
    	$this->display();
    }
    
    public function detail(){
    	$id = I('id',0);
    	if($id){
    		$this->info = $this->m->where('id = '.$id)->relation(true)->find();
    	}
    	$this->display();
    }
    
    public function get_more(){
    	$page = I('page',1);
    	$pdata = $this->_get_order(($page+1), $this->pagesize);
    	if($pdata){
    		$count = count($pdata);
    		if($count < $this->pagesize){
    			$next = 'no';
    		}else{
    			$next = 'yes';
    		}
    		$data = array(
    			'info' => 'ok',
    			'data' => $pdata,
    			'next' => $next,
    		);
    		
    	}else{
    		$data = array(
    			'info' =>'no',
    		);
    	}
    	$this->ajaxReturn($data);
    }

    public function _get_order($p,$pagesize){
    	$uid = session('_loginUser_home')['uid'];
    	return $this->list = D('YgclOrder')->where(array('uid'=>$uid))->page($p,$pagesize)->order('id desc')->select(); 
    }
}